package com.evan.designpatterns.proxy.dynamicproxy.jdkproxy;

import com.evan.designpatterns.proxy.Person;
import sun.misc.ProxyGenerator;

import java.io.FileOutputStream;
import java.io.IOException;

/**
 * @author :liujiapeng01
 * @date :2019-03-14 19:25
 **/
public class Test {


    public static void main(String[] args) throws IOException {
        Person instance = new Agency().getInstance(new Adult());
        instance.buy();


        byte[] bytes = ProxyGenerator.generateProxyClass("$Proxy", new Class[]{Person.class});
        FileOutputStream os = new FileOutputStream("$Proxy0.class");
        os.write(bytes);
        os.close();


    }
}
